package com.hp.airmap.input;

import com.hp.airmap.common.BasePresenter;
import com.hp.airmap.common.RetrofitUtil;
import com.hp.airmap.model.Photo;

import java.util.List;

import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 23hp on 2017/1/11.
 */

public class MvpPresenter extends BasePresenter<Contact.View> implements Contact.Presenter{

    @Override
    public void getPhotos() {
        Subscription subscription=RetrofitUtil.getWebService().getPhotos()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<List<Photo>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(List<Photo> photos) {
                        getView().onPhotosUpdate(photos);

                    }
                });
        mWrapper.add(subscription);

    }
}
